
package com.group8.ui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.event.ActionEvent;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.util.*;
import java.io.File;
import java.io.FileNotFoundException;

public class HelpPanel extends Menu{
	
	JLabel title;
	JButton back;
	JLabel line;

	int count = 140;
	
	public HelpPanel(){
		setLayout(null);
		setPreferredSize(new Dimension(800,660));
		this.setBackground(Color.YELLOW);
		back = new JButton();
		Image img = new ImageIcon("assets/main_menu/back.png").getImage();
		back.setIcon(new ImageIcon(img));
		back.setRolloverEnabled(false);
		back.setBounds(500,550,93,40);
		back.addActionListener(new ButtonListener());
		
		title = new JLabel("How To Play?");
		title.setBounds(255,40,500,100);
		title .setForeground(Color.RED);
		title.setFont(new Font("nfont", Font.PLAIN, 50));
		
		File file = new File("assets/hoptops_help.txt");
		
		try {

	        Scanner sc = new Scanner(file);

	        while (sc.hasNextLine()) {
	        	
	        	line = new JLabel(sc.nextLine());
	        	//line.setBounds(300,count,2000,70);
	        	line.setBounds(195,count, 2000, 35);
	        	line.setForeground(Color.DARK_GRAY);
	        	line.setFont(new Font("nfont", Font.ITALIC, 20));
	        	
	        	add(line);
	        	
	        	count += 30;
	         
	        }
	        sc.close();
	    } 
	    catch (FileNotFoundException e){
	    	e.printStackTrace();
	    }
		
		
		
		add(title);
		add(back);
	}
	
private class ButtonListener extends MenuActionListener{
		
		public void actionPerformed(ActionEvent e) {
			if(e.getSource() == back){
				switchPanels(getMain());
				System.out.println("Back clicked");
			}
		
		}
		
	}
}